package com.futu.es.controller;

import com.futu.common.annotation.NoLoginRequired;
import com.futu.common.vo.ResultVo;
import com.futu.es.dto.SpotByIdDto;
import com.futu.es.dto.SpotDto;
import com.futu.es.service.EsSoptService;
import com.futu.es.service.Impl.EsSoptServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("es")
public class SoptController {

    @Autowired
    private EsSoptServiceImpl esSoptService;



    @PostMapping("selectSopt")//搜索时出现下拉框
    @NoLoginRequired
    public ResultVo  selectSopt(@RequestBody SpotDto dto)
    {
        return esSoptService.selectSopt(dto);
    }

    @PostMapping("MysqlInterEs")//同步mysql数据到es
    @NoLoginRequired
    public ResultVo MysqlInterEs()
    {
        return esSoptService.MysqlInterEs();
    }


    @PostMapping("SelSopt")//记录用户访问呢的景点信息
    @NoLoginRequired
    public ResultVo SelSopt(@RequestBody SpotByIdDto dto)
    {
        return esSoptService.SelSopt(dto);
    }

    @PostMapping("recommend")//推荐游玩项目
    @NoLoginRequired
    public ResultVo recommend(HttpServletRequest request)
    {
        String token = request.getHeader("token");
        return esSoptService.recommend(token);
    }



}
